//! 配置服务错误定义

use thiserror::Error;
use nacos_core::NacosError;

#[derive(Debug, Error)]
pub enum ConfigError {
    #[error("Invalid configuration data: {0}")]
    InvalidData(String),

    #[error("Configuration not found: {0}")]
    NotFound(String),

    #[error(transparent)]
    Core(#[from] NacosError),
}

impl From<ConfigError> for NacosError {
    fn from(err: ConfigError) -> Self {
        match err {
            ConfigError::Core(core_err) => core_err,
            _ => NacosError::Config(err.to_string()),
        }
    }
}
